#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>

#include "log.h"
#include "dispatch.h"

static void print_usage(char *app)
{
	fprintf(stdout, "Usage:  %s <-r -s> <interface name> \n", app);
	fprintf(stdout, "        -r, --receive     Receive data test mode \n");
	fprintf(stdout, "        -s, --send        Send data test mode \n");
	fprintf(stdout, "        -l, --loopback    Send data test mode loopback\n");
	fprintf(stdout, "        -h, --help        Display this help \n");
	fprintf(stdout, "        -v, --version     Display this version \n");
	fprintf(stdout, "\n");
}

static void print_version(void)
{
	printf("Build GCC Version: %s \n", __VERSION__);
	printf("Build Date： %s \n", __DATE__);
	printf("Build Time %s \n", __TIME__);
	printf("\n");
}

int main(int argc, char* argv[])
{
	int32_t ret;
	struct dispatch* pdispatch;
	ret = create_init_dispatch(&pdispatch);
	if(ret < 0){
		DBG(DBG_ERR, "create init dispatch error\n");
		return ret;
	}
	ret = pdispatch->op->start(pdispatch);
	if(ret < 0){
		DBG(DBG_ERR, "dispatch start error\n");
		return ret;
	}

	printf("\n\n");
    printf("------------Interface Test Tools--------------\n\n");
	print_version();
	
	while(1){
#if 0
		sleep(1);
#else
		pdispatch->pshell->op->process(pdispatch->pshell);
#endif
	}
	pdispatch->op->stop(pdispatch);
	release_destroy_dispatch(pdispatch);
	return 0;
}
